package com.myprojects.webresources.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

@CrossOrigin
@Controller
//@RestController//注意！使用@RestController注解会附带@ResponseBody注解导致返回字符串信息
//@RequestMapping(value = "/auth")//这是该类的映射路径
public class TestController {

//    @RequestMapping(value = "/test")
    public String testDemo(){
        return "hello";
    }

    @RequestMapping(value = "/test")
    public String test(){
        return "index_1";
    }

    @RequestMapping(value = "/selectUser1")
    public String selectUser1(){
        return "example/selectUser";
    }

    /**
     * 该方法用于直接往模型里注入接口的字符串
     */
    public void setInterface(Model model){
        //"139.224.128.87"是远程服务器的地址，"localhost"是本地的地址，"192.168.43.64"是平板热点里的本机地址
//        String serverAddress = "localhost";//远程服务器地址
//        try {
//            InetAddress inetAddress = InetAddress.getLocalHost();
//            serverAddress = inetAddress.getHostAddress();;//获取字符串的主机地址
//        } catch (UnknownHostException e) {
//            e.printStackTrace();
//        }
//        System.out.println("serverAddress:"+serverAddress);
//
//        //跳转到登录页面的接口
//        model.addAttribute("to_login", "\"http://"+serverAddress+":9000/login\"");
//        //跳转到注册页面的接口
//        model.addAttribute("to_register", "\"http://"+serverAddress+":9000/register\"");
//        //跳转到主页面的接口
//        model.addAttribute("to_index", "\"http://"+serverAddress+":9000/index\"");
//        //跳转到简历管理的接口
//        model.addAttribute("to_resume", "\"http://"+serverAddress+":9000/resumeManage\"");
//        //跳转到实习员工的接口
//        model.addAttribute("to_internship", "\"http://"+serverAddress+":9000/internshipManage\"");
//        //跳转到正式员工的接口
//        model.addAttribute("to_regular", "\"http://"+serverAddress+":9000/regularManage\"");
//        //跳转到离职员工的接口
//        model.addAttribute("to_departure", "\"http://"+serverAddress+":9000/departureManage\"");
//        //登录接口
//        model.addAttribute("loginInterface", "\"http://"+serverAddress+":9002/loginByInfo\"");
//        //注册接口
//        model.addAttribute("registerInterface", "\"http://"+serverAddress+":9002/register\"");
//        //修改密码接口
//        model.addAttribute("changePasswordInterface", "\"http://"+serverAddress+":9002/password\"");
//        //获取全部门接口
//        model.addAttribute("getAllDepartmentsInterface", "\"http://"+serverAddress+":9003/department-curd/departments\"");
//        //部门接口
//        model.addAttribute("departmentInterface", "\"http://"+serverAddress+":9003/department-curd/department\"");
//        //职位接口
//        model.addAttribute("positionInterface", "\"http://"+serverAddress+":9003/position-curd/positions\"");
//        //员工接口
//        model.addAttribute("employeeInterface", "\"http://"+serverAddress+":9003/employee-curd/employee\"");
//        //实习员工接口
//        model.addAttribute("internshipInterface", "\"http://"+serverAddress+":9003/employee-curd/internship\"");
//        //正式员工接口
//        model.addAttribute("regularInterface", "\"http://"+serverAddress+":9003/employee-curd/regular\"");
//        //离职员工接口
//        model.addAttribute("departureInterface", "\"http://"+serverAddress+":9003/employee-curd/departure\"");
//        //简历接口
//        model.addAttribute("resumeInterface", "\"http://"+serverAddress+":9003/employee-curd/resume\"");
//        //民族数据接口
//        model.addAttribute("nationInterface", "\"http://"+serverAddress+":9003/employee-curd/nation\"");
//        //获取全部门(带职位)接口
//        model.addAttribute("getAllDepartmentsWithPositions", "\"http://"+serverAddress+":9003/position-curd/getAllDepartmentsWithPositions\"");
//        //权限接口
//        model.addAttribute("permissionInterface", "\"http://"+serverAddress+":9004/perm\"");
//        //用户(带角色)接口
//        model.addAttribute("userWithRoleInterface", "\"http://"+serverAddress+":9004/user-with-role-curd/users\"");
//        //用户(不修改角色)接口
//        model.addAttribute("userInterface", "\"http://"+serverAddress+":9004/user-with-role-curd/users_without_role\"");
//        //角色接口
//        model.addAttribute("roleInterface", "\"http://"+serverAddress+":9004/role-curd/roles\"");
//        //获取全角色接口
//        model.addAttribute("getAllRoleInterface", "\"http://"+serverAddress+":9004/user-with-role-curd/roles\"");
//        //获取全资源接口
//        model.addAttribute("getAllResourceInterface", "\"http://"+serverAddress+":9004/resource-curd/resources\"");
    }
}

